$(document).on('switchChange.bootstrapSwitch', '.switch', function (e, state) {
    var checkbox = $(this);
    $.getJSON(
        checkbox.data('link') + '/' + (state ? 'on' : 'off') + '?id=' + checkbox.data('id'),
        function (response) {
            console.log(response);
            if (checkbox.data('reload')) {
                location.reload();
            }
            if (response.result === 'error') {
                swal({
                    title: "失败",
                    text: response.message,
                    type: "error"
                });
            }
        }
    );
});